package leetcode

func reverse(x int) int {
	var r = 0
	for x != 0 {
		if int(int32(r*10)/10) != r {
			return 0
		}
		r = r*10 + x%10

		x = x / 10
	}
	return r
}
